<?php
$link = $modx->resource->get('longtitle');
function createSrc($link) {
    if(!$default) $default = array('src'=>$link, 'img_src_mini'=>$link);
    preg_match('/http:\/\/youtu.be\/(.*)/', $link, $res);
    if(!isset($res[1]))
        preg_match('/http:\/\/www.youtube.com\/watch\?v=([^&]*)/', $link, $res); 
    if(!isset($res[1]))
    	preg_match('/http:\/\/www.youtube.com\/v\/([^?]*)/', $link, $res);
    if(!isset($res[1]))
    	return $default;
    $v = $res[1];
    $src = 'http://www.youtube.com/embed/'.$v.'?feature=player_detailpage&wmode=transparent';
    $img_src = 'http://img.youtube.com/vi/'.$v.'/0.jpg';
    $img_src_mini = 'http://img.youtube.com/vi/'.$v.'/1.jpg';
    return array('v' => $v, 'src' => $src, 'img_src' => $img_src, 'img_src_mini' => $img_src_mini);
}
switch($get){
    case "src":
        $output .= $modx->getChunk($tpl,createSrc($link));
        break;
    case "img_src_mini":
        $childrens =  $modx->resource->getMany('Children');
        foreach ($childrens as $child) {
            $url = $child->toArray();
            $output .= $modx->getChunk($tpl,array_merge(createSrc($url["longtitle"]),$url));
        }
        break;
    default: return $link;
}
return $output;